package com.ztesoft.report;

import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;

import java.util.Properties;

/**
 * @author y3tu
 * @date 2018/5/30
 */
@SpringBootApplication
@PropertySource(value ="classpath:backStageJob.properties")
public class ReportApplication {
    @Value("${com.ztesoft.dataBaseDialect}")
    private String dialect;

    public static void main(String[] args) {
        SpringApplication.run(ReportApplication.class, args);
    }

    /** 配置mybatis的分页插件pageHelper */
    @Bean
    public PageHelper pageHelper(){
        //第一步是添加POM.xml文件里分页插件的依赖
        //第二步是在springBoot的主加载类里配置分页插件
        PageHelper pageHelper = new PageHelper();
        Properties properties = new Properties();
        properties.setProperty("offsetAsPageNum","true");
        properties.setProperty("rowBoundsWithCount","true");
        properties.setProperty("reasonable","true");
        //配置mysql数据库的方言
        properties.setProperty("dialect",dialect);
        pageHelper.setProperties(properties);
        return pageHelper;
    }
}
